
// 续费菜单
function XufeiBtn(id){
	document.location.href = 'usersCenter.php?mudi=vpsManage_xufei&dataID='+ id +'&backURL='+ encodeURIComponent(document.location.href);
}


// 升级菜单
function UpdateBtn(id){
	document.location.href = 'usersCenter.php?mudi=vpsManage_update&dataID='+ id +'&backURL='+ encodeURIComponent(document.location.href);
}


// 转正菜单
function ZhuanzhengBtn(id){
	document.location.href = 'usersCenter.php?mudi=vpsManage_zhuanzheng&dataID='+ id +'&backURL='+ encodeURIComponent(document.location.href);
}


// 退款菜单
function TuikuanBtn(id){
	document.location.href = 'usersCenter.php?mudi=vpsManage_tuikuan&dataID='+ id +'&backURL='+ encodeURIComponent(document.location.href);
}


// 查询框
function CheckRefForm(){
	var refUrlStr = '';
	var refNum = 0;
	if ($id('refProName').value != ""){ refNum ++; refUrlStr += '&refProName='+ encodeURIComponent($id("refProName").value) +''; }
	if ($id('refVpsName').value != ""){ refNum ++; refUrlStr += '&refVpsName='+ encodeURIComponent($id("refVpsName").value) +''; }
	if ($id('refIp').value != ""){ refNum ++; refUrlStr += '&refIp='+ encodeURIComponent($id("refIp").value) +''; }
	if ($id('refDate1').value != ""){ refNum ++; refUrlStr += '&refDate1='+ encodeURIComponent($id("refDate1").value) +''; }
	if ($id('refDate2').value != ""){ refNum ++; refUrlStr += '&refDate2='+ encodeURIComponent($id("refDate2").value) +''; }
	if ($id('refEndDate1').value != ""){ refNum ++; refUrlStr += '&refEndDate1='+ encodeURIComponent($id("refEndDate1").value) +''; }
	if ($id('refEndDate2').value != ""){ refNum ++; refUrlStr += '&refEndDate2='+ encodeURIComponent($id("refEndDate2").value) +''; }
	if (refNum == 0){ alert("请先输入查询条件");$id('refProName').focus();return false; }
	document.location.href='usersCenter.php?mudi=vpsManage'+ refUrlStr;
	return false;
}


// 开通表单
function CheckKaitongForm(){
	if ($id('vpsPwd').value == ''){ alert("请先输入 云服务器密码");$id('vpsPwd').focus();return false; }
	if ($id('vpsPwd').value.length < 8){ alert("云服务器密码不能低于8位数");$id('vpsPwd').focus();return false; }
	if ($id('payMode').value == ''){ alert("请选择 付款方式");$id('payMode').focus();return false; }

	var payPice = -1;
	var payName = '';
	switch ($id('payMode').value){
		case '24hour':		payName = '试用24小时'; 	payPice = $id('price24Hour').value;		break;
		case '48hour':		payName = '试用48小时'; 	payPice = $id('price48Hour').value;		break;
		case 'day':		payName = '日付';		payPice = $id('priceDay').value;		break;
		case 'week':		payName = '周付';		payPice = $id('priceWeek').value;		break;
		case 'month':		payName = '月付';		payPice = $id('priceMonth').value;		break;
		case '3month':		payName = '季付';		payPice = $id('price3Month').value;		break;
		case '6month':		payName = '半年付';		payPice = $id('price6Month').value;		break;
		case 'year':		payName = '一年付';		payPice = $id('priceYear').value;		break;
		case 'year2':		payName = '两年付';		payPice = $id('priceYear').value*2;		break;
		case 'year3':		payName = '三年付';		payPice = $id('priceYear').value*3;		break;
		case 'year4':		payName = '四年付';		payPice = $id('priceYear').value*4;		break;
		case 'year5':		payName = '五年付';		payPice = $id('priceYear').value*5;		break;
	}

	if (payPice < 0){ alert("请选择付款方式");return false; }

	remMoney = formatFlt2(accMin($id('userMoney').value,payPice));
	if (remMoney < 0){
		alert("用户余额不足（"+ $id('userMoney').value +" - "+ payPice +" = "+ remMoney +"），请充值或者选择付款少些的付款方式");return false;
	}

	// 判断字符串是否为数字和字母组合
	var zg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]*$/;
	if (! zg.test($id('vpsPwd').value)){
		if (confirm("检测到服务器密码不是同时含字母和数字，这样有一定概率会开通失败？\n建议修改密码为同时含字母和数字\n继续开通请点【确定】，修改密码请点【取消】。")==false){
			return false;
		}
	}

	if (confirm("您确定要开通 "+ $id('proName').value +" "+ payName +"？\n\n用户余额预计："+ remMoney +" 元（"+ $id('userMoney').value +"元 - "+ payPice +"元）\n\n【提醒】开通过程预计需要10~40秒，中途千万不要有其他操作，防止开通失败，静静等待结果。")==false){
		return false;
	}

	$id('userPrice').value = payPice;
	try{ $id('dealAlert').style.display = ''; }catch (e){}

	ShowMengceng('正在开通中，请等待...',50);

	return true;
}


// 续费表单
function CheckXufeiForm(){
	var payPice = 0;
	var payName = '';
	if ($id('payMode_month').checked){ payName = '一个月'; payPice = $id('priceMonth').value; }
	else if ($id('payMode_3month').checked){ payName = '一季'; payPice = $id('price3Month').value; }
	else if ($id('payMode_6month').checked){ payName = '半年'; payPice = $id('price6Month').value; }
	else if ($id('payMode_year').checked){ payName = '一年'; payPice = $id('priceYear').value; }
	else if ($id('payMode_year2').checked){ payName = '两年'; payPice = $id('priceYear').value*2; }
	else if ($id('payMode_year3').checked){ payName = '三年'; payPice = $id('priceYear').value*3; }

	if (payPice <= 0){ alert("请选择续费时间");return false; }

	remMoney = formatFlt2(accMin($id('userMoney').value,payPice));
	if (remMoney < 0){
		alert("用户余额不足（"+ $id('userMoney').value +" - "+ payPice +" = "+ remMoney +"），请充值或者选择短些续费时间");return false;
	}

	if (confirm("您确定要续费"+ payName +"？\n\n用户余额预计："+ remMoney +" 元（"+ $id('userMoney').value +"元 - "+ payPice +"元）\n\n【提醒】续费过程预计需要3~20秒，中途千万不要有其他操作，防止续费失败，静静等待结果。")==false){
		return false;
	}

	$id('userPrice').value = payPice;
	try{ $id('dealAlert').style.display = ''; }catch (e){}

	ShowMengceng('正在续费中，请等待...',50);

	return true;
}


// 升级表单
function CheckUpdateForm(){
	if ($id('proDataID').value == ''){ alert("请先选择要升级的产品");$id('proDataID').focus();return false; }

	updatePrice = $id('updatePrice'+ $id('proDataID').value).value;
	remMoney = formatFlt2(accMin($id('userMoney').value,updatePrice));
	if (remMoney < 0){
		alert("用户余额不足（"+ $id('userMoney').value +" - "+ updatePrice +" = "+ remMoney +"），请先充值。");return false;
	}

	if (confirm("您确定要升级产品：\n"+ SelectGetText('proDataID') +"？\n\n用户余额预计："+ remMoney +" 元（"+ $id('userMoney').value +"元 - "+ updatePrice +"元）\n\n【提醒】升级产品过程预计需要3~30秒，中途千万不要有其他操作，防止升级失败，静静等待结果。")==false){
		return false;
	}

	$id('userPrice').value = updatePrice;
	try{ $id('dealAlert').style.display = ''; }catch (e){}

	ShowMengceng('正在升级中，请等待...',50);

	return true;
}


// 转正表单（废弃）
function CheckZhuanzhengForm2(){
	var payPice = 0;
	var payName = '';
	if ($id('payMode_month').checked){ payName = '一个月'; payPice = $id('priceMonth').value; }
	if ($id('payMode_3month').checked){ payName = '一季'; payPice = $id('price3Month').value; }
	if ($id('payMode_6month').checked){ payName = '半年'; payPice = $id('price6Month').value; }
	if ($id('payMode_year').checked){ payName = '一年'; payPice = $id('priceYear').value; }
	if ($id('payMode_year2').checked){ payName = '两年'; payPice = $id('priceYear').value*2; }
	if ($id('payMode_year3').checked){ payName = '三年'; payPice = $id('priceYear').value*3; }

	if (payPice <= 0){ alert("请选择转正时间");return false; }

	remMoney = formatFlt2(accMin($id('userMoney').value,payPice));
	if (remMoney < 0){
		alert("用户余额不足（"+ $id('userMoney').value +" - "+ payPice +" = "+ remMoney +"），请充值或者选择短些转正时间");return false;
	}

	if (confirm("您确定要转正"+ payName +"？\n\n用户余额预计："+ remMoney +" 元（"+ $id('userMoney').value +"元 - "+ payPice +"元）\n\n【提醒】转正过程预计需要3~20秒，中途千万不要有其他操作，防止转正失败，静静等待结果。")==false){
		return false;
	}

	$id('userPrice').value = payPice;
	try{ $id('dealAlert').style.display = ''; }catch (e){}

	return true;
}


// 转正表单
function CheckZhuanzhengForm(){
	if (confirm("您确定要转正？\n\n【提醒】转正过程预计需要3~20秒，中途千万不要有其他操作，防止转正失败，静静等待结果。")==false){
		return false;
	}

	ShowMengceng('正在转正中，请等待...',50);

	return true;
}


// 退款表单
function CheckTuikuanForm(){
	if (confirm("您确定要退款？")==false){
		return false;
	}

	ShowMengceng('正在退款中，请等待...',50);

	return true;
}


// 自动续费处理
function AutoXufeiDeal(id){
	if ($id('isAutoXufei'+ id).checked){ axVal = 1; }else{ axVal = 0; }
	AjaxGetDeal('usersVps_deal.php?mudi=autoXufeiDeal&type=vpsApi&dataID='+ id +'&valNum='+ axVal);
}